﻿namespace EasyPO
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using NLog;
    using NLog.Config;
    using System.IO;

    public static class EasyPoLog
    {

        public static void LogError(string customMessage = "", Exception ex = null)
        {
            // destroy file if it reaches a certain size (appx: 10MB)
            var fileName = @"C:\Temp\EasyPo_Errors_Log.txt";
            var f = new FileInfo(fileName);
            if (f.Length > 10000000)
                File.Delete(fileName);

            logger.ErrorException("\n******************************\nGot exception.\nCustom message: " + customMessage + "\n", ex);

        }

        private static Logger logger = LogManager.GetCurrentClassLogger();
    }
}
